package com.cmcc.aregister.ui.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.asntask.InterfaceUtils.DataCallback_other;
import com.cmcc.aregister.cs.model.ScheduleModel;

public class ChoiceOtherSchAdapter extends BaseAdapter {
    private Context context = null;
    public List<ScheduleModel> list = null;
    public boolean isEnd = true;
    DataCallback_other inc;

    public ChoiceOtherSchAdapter(Context context, List<ScheduleModel> list,
        boolean isEnd, DataCallback_other inc) {
        this.context = context;
        this.list = list;
        this.isEnd = isEnd;
        this.inc = inc;
    }

    public int getCount() {
        int size = list.size();
        return size + 1;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(
                R.layout.a_choice_time, null);
            holder.name = (TextView) convertView.findViewById(R.id.name);

            holder.left_num = (TextView) convertView
                .findViewById(R.id.left_num);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (position > (list.size() - 1)) {
            holder.name.setText(context.getString(R.string.kefu_sch));
            // holder.left_num.setVisibility(View.GONE);
        }
        else {
            ScheduleModel schedule = list.get(position);
            holder.name.setText(schedule.healDate + " "
                + context.getString(R.string.left_num) + "(" + schedule.number
                + ")");
            holder.left_num.setText(schedule.weekDay + " " + schedule.dayTime);
        }
        return convertView;
    }

    static class ViewHolder {
        TextView name;
        TextView left_num;
    }
}